import { IPSDELogic } from './ipsdelogic';
import { IPSDELogicParam } from './ipsdelogic-param';
import { IPSDESysSearchDocActionLogic } from './ipsdesys-search-doc-action-logic';
import { PSDELogicNodeImpl } from './psdelogic-node-impl';
import { IPSSysSearchDoc } from '../../search/ipssys-search-doc';
import { IPSSysSearchScheme } from '../../search/ipssys-search-scheme';

export class PSDESysSearchDocActionLogicImpl extends PSDELogicNodeImpl implements IPSDESysSearchDocActionLogic {
  protected dstpsdelogicparam: IPSDELogicParam | null = null;

  getDstPSDELogicParam(): IPSDELogicParam | null {
    if (this.dstpsdelogicparam != null) return this.dstpsdelogicparam;
    const value = this.M.getDstPSDELogicParam;
    if (value == null) {
      return null;
    }
    const ipsdelogic = this.getParentPSModelObject('dataentity.logic.IPSDELogic') as IPSDELogic;
    if (ipsdelogic != null) {
      this.dstpsdelogicparam = ipsdelogic.findPSDELogicParam(value);
    }
    return this.dstpsdelogicparam;
  }

  get dstPSDELogicParam(): IPSDELogicParam | null {
    return this.getDstPSDELogicParam();
  }

  getDstPSDELogicParamMust(): IPSDELogicParam {
    const value = this.getDstPSDELogicParam();
    if (value == null) {
      throw new Error('未指定目标逻辑参数对象');
    }
    return value;
  }

  protected pssyssearchdoc: IPSSysSearchDoc | null = null;

  getPSSysSearchDoc(): IPSSysSearchDoc | null {
    if (this.pssyssearchdoc != null) return this.pssyssearchdoc;
    const value = this.M.getPSSysSearchDoc;
    if (value == null) {
      return null;
    }
    const ipssyssearchscheme = this.getPSSysSearchScheme();
    if (ipssyssearchscheme != null) {
      this.pssyssearchdoc = ipssyssearchscheme.findPSSysSearchDoc(value);
    }
    return this.pssyssearchdoc;
  }

  get psSysSearchDoc(): IPSSysSearchDoc | null {
    return this.getPSSysSearchDoc();
  }

  getPSSysSearchDocMust(): IPSSysSearchDoc {
    const value = this.getPSSysSearchDoc();
    if (value == null) {
      throw new Error('未指定检索文档');
    }
    return value;
  }

  protected pssyssearchscheme: IPSSysSearchScheme | null = null;

  getPSSysSearchScheme(): IPSSysSearchScheme | null {
    if (this.pssyssearchscheme != null) return this.pssyssearchscheme;
    const value = this.M.getPSSysSearchScheme;
    if (value == null) {
      return null;
    }
    this.pssyssearchscheme = this.getPSModel4('search.IPSSysSearchScheme', value, 'getPSSysSearchScheme') as IPSSysSearchScheme;
    return this.pssyssearchscheme;
  }

  get psSysSearchScheme(): IPSSysSearchScheme | null {
    return this.getPSSysSearchScheme();
  }

  getPSSysSearchSchemeMust(): IPSSysSearchScheme {
    const value = this.getPSSysSearchScheme();
    if (value == null) {
      throw new Error('未指定全文检索体系');
    }
    return value;
  }

  get searchDocAction(): 'CREATE' | 'UPDATE' | 'READ' | 'DELETE' {
    return this.M.searchDocAction;
  }

  get cls(): string {
    return 'PSDESysSearchDocActionLogicImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'dataentity.logic.IPSDESysSearchDocActionLogic') return true;
    return super.instanceof(cls);
  }
}
